#include <iostream>
#include <mutex>

using namespace std;

void prepare_data(){};

std::unique_lock<std::mutex> get_lock()
{
    //lock create
    extern std::mutex some_mutex;

    //lk will be declared an auto variable
    //no need move(),compiler will call move construct automaticly
    std::unique_lock<std::mutex> lk(some_mutex);
    prepare_data();

    return lk;
}

void do_something(){};

void process_data()
{
    //get lock with function deliver the param
    unique_lock<mutex> lk(get_lock());

    do_something();
}


int main()
{
    std::cout << "Hello world" << std::endl;
    return 0;
}

